<div>
  <div class="pull-right">
    <%= link_to "新建商品", new_admin_product_path, class: "btn btn-primary" %>
  </div>

  <h1>
    商品(<%= @products.total_entries %>)
  </h1>
</div>

<div>
  <table class="table table-striped">
    <tr>
      <th>ID</th>
      <th width="15%">名称</th>
      <th width="10%">分类</th>
      <th>类型</th>
      <th>品牌</th>
      <th>规格</th>
      <th>UUID/SKU</th>
      <th>是否为畅销</th>
      <th class="text-right">促销价</th>
      <th class="text-right">市场价</th>
      <th class="text-right">库存</th>
      <th>状态</th>
      <th>操作</th>
    </tr>

    <% @products.each do |product| %>
      <tr>
        <td><%= product.id %></td>
        <td><%= link_to product.title, product_path(product) %></td>
        <td><%= product.category_titles %></td>
        <td><%= product.product_type_i18n %></td>
        <td><%= product.brand_title %></td>
        <td><%= product.spec_title %></td>
        <td><%= product.uuid %></td>
        <td><%= product.is_top ? "是" : "否" %></td>
        <td class="text-right"><%= product.msrp %></td>
        <td class="text-right"><%= product.price %></td>
        <td class="text-right"><%= product.stock.amount %></td>
        <td><%= product.status_i18n %></td>
        <td>
          <%= link_to "编辑", edit_admin_product_path(product) %>
          <%= link_to product.on? ? "下架" : "上架", set_on_or_off_admin_products_path(id: product.id), method: :post %>
          <%= link_to product.is_top ? "取消设置为畅销" : "设置为畅销", enable_top_or_disable_top_admin_products_path(id: product.id), method: :post %>
          <%= link_to "删除", admin_product_path(product), method: :delete, 'data-confirm': "确认删除吗?" %>
          <%= link_to "图片管理", admin_product_product_images_path(product_id: product) %>
        </td>
      </tr>
    <% end -%>
  </table>

  <%= will_paginate @products %>
</div>
